<template>
  <div>

  </div>
</template>

<script>
import { _deepClone } from '@/utils'

export default {
  name: 'handleSubmit',
  data() {
    return {

    }
  },
  methods: {
    // --------------------------------------mixin方法重写--------------------------------------

    //打开弹窗
    showDialog() {
      if(this.disabled) return
      this.$emit("showDialog");
      this.$refs.ChooseDialog.show();
      if (this.selectName) this.tempVal = _deepClone(this.selectName)
      if(this.selectId) this.isCheckValue = _deepClone(this.selectId)
      this.resetQueryForm()
      this.handleTreeList();
    },

    //树节点点击事件
    setQueryForNode(info) {
      this.queryForm.name = "";
      this.queryForm.id = info.data.name === '自定义' || info.data.name === '预定义'
          ? '0'
          : info.data.id
      this.queryForm.isDefault = info.data.isDefault
      this.queryForm.pageNum = 1
      this.queryForm.pageSize = 10
    },

    //重置筛选条件
    resetForm() {
      this.queryForm.name = "";
    },
    //弹窗提交事件
    submit() {
      if (!this.selectRow && !this.isCheckValue) {
        this.isClosed = false;
        return this.$GlobalErrorConfirm("添加失败", `请选择${this.title}！`);
      }
      console.log(this.isCheckValue);
      this.isClosed = true;
      this.tempVal = this.selectRow ? this.selectRow.name : this.tempVal
      let selectRow = this.selectRow || {name: this.tempVal, [this.key]: this.isCheckValue}
      console.log(selectRow);
      this.$emit(
          "submitDialog",
          selectRow,
      );
    },
    //清除选中数据
    handleClose() {
      this.isCheckValue = "";
      this.tempVal = "";
      this.selectRow = null;
      this.$emit("clearInfo");
      // this.$emit('submitDialog', this.selectRow) 用的地方加判断太麻烦了
    },


    handleTreeList() {
      this.treeLoading = true
      this.allList = []
      this.listLoading = true
      this.getTreeList().then(res => {
        this.treeData = res
        this.currentNodeKey = '0'
      }).catch(err => {
        // 统一异常处理
      }).finally(() => {
        this.treeLoading = false
      })
    },

    resetQueryForm() {}
  },
}
</script>

<style scoped>

</style>
